from django.urls import re_path
from meiduo_admin.views import users, skus, channels, spus, permissions
from meiduo_admin.views import statistical
from rest_framework.routers import SimpleRouter

urlpatterns = [
    re_path(r'^authorizations/$', users.AdminAuthorizeView.as_view()),
    re_path(r'^statistical/day_active/$', statistical.UserDayActiveView.as_view()),
    re_path(r'^statistical/day_orders/$', statistical.UserDayOrdersView.as_view()),
    re_path(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    re_path(r'^statistical/day_increment/$', statistical.UserDayIncrementView.as_view()),
    re_path(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    re_path(r'^statistical/goods_day_views/$', statistical.GoodsDayViewsView.as_view()),
    re_path(r'^users/$', users.UserInfoView.as_view()),
    re_path(r'^skus/simple/$', skus.SKUSimpleView.as_view()),
    re_path(r'^goods/channel_types/$', channels.ChannelTypesView.as_view()),
    re_path(r'^goods/categories/$', channels.GoodsCategoriesView.as_view()),
    re_path(r'^goods/channel/categories/$', spus.GoodsCategoriesView.as_view()),
    re_path(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.GoodsChannelCategoriesView.as_view()),
    re_path(r'^goods/brands/simple/$', spus.GoodsBrandsSimpleView.as_view()),
    re_path(r'^permission/content_types/$', permissions.PermissionViewSet.as_view({
        'get': 'content_types'
    })),
    # 用户组管理
    re_path(r'^permission/simple/$', permissions.GroupViewSet.as_view({
        'get': 'simple'
    })),
    # 管理员管理
    re_path(r'^permission/groups/simple/$', permissions.AdminViewSet.as_view({
        'get': 'simple'
    })),
]
router = SimpleRouter()
router.register('skus/images', skus.SKUImageViewSet, basename='images')
urlpatterns += router.urls
router.register('goods/channels', channels.GoodsChannelViewSet, basename='channels')
urlpatterns += router.urls
router.register('goods', spus.SpusGoodsViewSet, basename='spu')
urlpatterns += router.urls
router.register('permission/perms', permissions.PermissionViewSet, basename='perms')
urlpatterns += router.urls
router.register('permission/groups', permissions.GroupViewSet, basename='groups')
urlpatterns += router.urls
router.register('permission/admins', permissions.AdminViewSet, basename='admins')
urlpatterns += router.urls
